Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ezez/errors

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ezez/errors

JavaScript's errors with superpowers! ⚡

  • 6.0.2
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
859
increased by57.33%
Maintainers
1
Weekly downloads
 
Created
Source

@ezez/errors

JavaScript's errors with superpowers! ⚡

Features:

  • 🛠 First class TypeScript support - 100% type safe and intellisense friendly
  • 📝 Attach extra data to an error - debug with ease
  • 🪬 Give your errors a meaningful name - improve code readability
  • 🧱 Build your errors on top of another - access the whole hierarchy
  • 🌟 Bonus features - clean up your stack traces, normalize non-errors
  • 📦 No dependencies - use it anywhere
  • 🌎 Universal - exposes both ESM modules and CommonJS

Usage

Full documentation, including TypeScript usage available here: documentation.

npm i @ezez/errors --save

import { createError } from "@ezez/errors";
// or const { createError } = require("@ezez/errors");

const DatabaseError = createError("DatabaseError");
const QueryError = createError("QueryError", DatabaseError); // it extends `Error` by default, but you can pass another error
const InsertQueryError = createError("InsertQueryError", QueryError, { cleanStackTraces: false });

// then

try {
    throw new DatabaseError("Connection lost", { date: Date.now(), { ... } });
}
catch (e) {
    if (e instanceof DatabaseError) {
        console.error(e.details?.date, e.message);
    }
}

License

MIT

FAQs

Package last updated on 17 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc